package one;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

@SuppressWarnings("deprecation")
public class Scenario4 extends SeleneseTestCase {
	public SeleniumServer rs;
	@Before
	public void setUp() throws Exception {
		rs=new SeleniumServer();
		rs.start();
		selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.rightstart.com/");
		
		selenium.start();
	}
	



	@Test
	public void testUntitled() throws Exception {
		selenium.open("/");
		selenium.windowMaximize();
		selenium.type("id=search","toys");
		selenium.click("class=btn_search");
		selenium.waitForPageToLoad("60000");
		selenium.click("id=product_list-small_image-img-564");
		selenium.waitForPageToLoad("60000");
		selenium.type("id=qty","1");
		//price of the product
		//save price of the product
				String price = selenium.getText("product-price-564");
				//print price of the product
				System.out.println("price="+price);
				//Add product to the cart
				selenium.click("class=btn_add_to_cart2");
				//click on view cart and checkout
				
				selenium.click("id=cartHeader");
				selenium.click("css=span > span");
				selenium.waitForPageToLoad("60000");
				
				//save total price --- a
				String priceA = selenium.getText("class=price");
				//scrolldown
				selenium.getEval("window.scrollBy(0,500)");
				//get quote for your state,select value from dropdown
				selenium.select("id=region_id","label=California");
				Thread.sleep(5000);
				selenium.click("type=button");
				//type zipcode
				selenium.type("id=postcode","95051");
				//select shipping option(ground)
				selenium.check("id=s_method_udropship_ground");
				Thread.sleep(5000);
				//click update total
				selenium.click("type=submit");
				selenium.waitForPageToLoad("60000");
				//save grand total ----b
				String priceB = selenium.getText("\\td[@class='a-right']/span");
				//compare A and B values
				if(String(priceA, priceB))
				{
					System.out.println("priceA");
				}
				else
				{
					System.out.println("pricaA!= priceB");
				}
				
				//proceed to checkout
				selenium.click("class=button btn-proceed-checkout checkout button");
				//checkout as Already a Customer
				selenium.type("id=login-email","vij_siri81@yahoo.com");
				selenium.type("id=login-password","sarada123");
				//click on continue 
				selenium.click("//div[@class='login:guest']/span");
				//type billing information
				selenium.type("id=billing:firstname", "sirisha");
				selenium.type("id=billing:lastname", "bollu");
				selenium.type("id=billing:email","vij_siri81@yahoo.com");
				selenium.type("id=billing:street1","3665 Benton Street");
				selenium.type("id=billing:city","Sunnyvale");
				selenium.select("id=billing:region_id","lable=California");
				selenium.type("id=billing:postcode","98086");
				selenium.select("id=billing:country_id","lable=United States");
				selenium.type("id=billing:telephone","4087274774");
				selenium.click("id=billing:use_for_shipping_yes");
				selenium.click("class=button");
				//click on continue
				selenium.click("class=button");
				//check creditcard or debit card option
				selenium.check("id=p_method_payware");
				//select credit card type
				selenium.select("id=payware_cc_type","lable=Visa");
				selenium.type("id=payware_cc_number","4012888888881881");
				selenium.select("id=payware_expiration","lable=01 January");
				selenium.select("id=payware_expiration_yr","2013");
				selenium.type("id=payware_cc_cid","234");
				selenium.click("class=button");
				//save grand total ----C
				String priceC = selenium.getText("\\td[@class='a-right last']/span");
				//compare A and C
				if(String(priceA, priceC))
				{
					System.out.println("priceA");
				}
				else
				{
					System.out.println("pricaA!= priceC");
				}
				selenium.click("class=button btn-checkout");
			
	
		Thread.sleep(5000);
		
	}

	private boolean String(String priceA, String priceC) {
		// TODO Auto-generated method stub
		return false;
	}




	@After
	public void tearDown() throws Exception {
		selenium.stop();
		rs.stop();
	}
}

